﻿-- =============================================
-- Author:		<Author,,Name>
-- Create date: <Create Date,,>
-- Description:	<Description,,>
-- =============================================
CREATE PROCEDURE [dbo].[proc_Customer_CheckCusAudit]
(
	@CusId uniqueidentifier,
	@AuditPerson nvarchar(30)
)
AS
BEGIN
	Declare @EName nvarchar(30)
	Update Customer Set AuditPerson=@AuditPerson Where CustomerId=@CusId And Audit=0 And AuditPerson Is Null

	Set @EName = IsNull((Select AuditPerson From Customer Where CustomerId=@CusId),@AuditPerson)
	
	Set @EName = IsNull((Select Top 1 EName From Employee Where UserName=@EName),'')
	Select @EName As AuditPerson
END